package oms.service;

import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import oms.dao.OrderDAO;
import oms.entities.Order;
import oms.entities.User;

@Service
public class OrderServiceImpl implements OrderService {

		@Autowired 
		private OrderDAO orderDAO;

		@Transactional
		public void createOrder(Order order) {
			
				orderDAO.createOrder(order);
		}
		
		@Transactional
		public void saveOrder(Long orderId) {
			
				orderDAO.saveOrder(orderId);
		}

		@Transactional
		public void updateOrder(Long orderId) {
		
				orderDAO.updateOrder(orderId);
		}
		
		@Transactional
		public void deleteOrder(Long orderId) {
			
				orderDAO.deleteOrder(orderId);
		}

		public Order getOrderById(Long orderId) {
		
				return orderDAO.getOrderById(orderId);
		}
		
		@Transactional
		public List<Order> ordersList() {
		
				return orderDAO.ordersList();
		}

		@SuppressWarnings("rawtypes")
		@Transactional
		public Collection getOrdersByUser(User user) {
	
				return orderDAO.getOrdersByUser(user);
		}
}